﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;

namespace TianShu.WebApi
{
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class TianShuDeleteController<TKey> : TianShuController
    {
        protected readonly IDeleteAppService<TKey> DeleteService;
        public TianShuDeleteController(IDeleteAppService<TKey> deleteService)
        {
            this.DeleteService = deleteService;
        }

        [HttpDelete("deleteids")]
        public virtual async Task<IActionResult> Delete([FromBody] IEnumerable<TKey> id)
        {
            var result = await DeleteService.DeleteAsync(id);
            return Json(result);
        }
        [HttpDelete("delete")]
        public virtual async Task<IActionResult> Delete([FromQuery] TKey id)
        {
            var result = await DeleteService.DeleteAsync(new List<TKey> { id });
            return Json(result);
        }
    }
}
